package com.youth.utils;

import com.youth.entity.po.Order;
import com.youth.entity.po.OrderItem;
import com.youth.entity.po.OrderShipping;
import com.youth.entity.vo.OrderItemVO;
import com.youth.entity.vo.OrderShippingVO;
import com.youth.entity.vo.OrderVO;

import java.util.Date;
import java.util.UUID;

/**
 * @ClassName OrderCodeUtils
 * @Description: TODO
 * @Author yjwu
 * @Date 2019/10/30 21:41
 **/
public class OrderUtils {

    public static String getOrderCode() {
        UUID uuid = UUID.randomUUID();
        return uuid.toString().replaceFirst("-", "");
    }


    public static Order orderVoToOrder(OrderVO orderVO) {
        Order order = new Order();
        order.setUserId(orderVO.getUserId());
        order.setOrderId(orderVO.getOrderId());
        order.setBuyerNick(orderVO.getBuyerNick());
        order.setBuyerRate(order.getBuyerRate());
        order.setBuyerMessage(orderVO.getBuyerMessage());
        order.setShippingCode(orderVO.getShippingCode());
        order.setShippingName(orderVO.getShippingName());
        order.setStatus(orderVO.getStatus());
        order.setPayment(orderVO.getPayment());
        order.setPostFee(orderVO.getPostFee());
        return order;
    }


    public static OrderItem orderItemVOToOrderItem(OrderItemVO orderItemVO) {

        OrderItem orderItem = new OrderItem();

        orderItem.setOrderId(orderItemVO.getOrderId());
        orderItem.setTCId(orderItemVO.getTCId());
        orderItem.setNum(orderItemVO.getNum());
        orderItem.setTitle(orderItemVO.getTitle());
        orderItem.setPrice(orderItemVO.getPrice());
        orderItem.setPicPath(orderItemVO.getPicPath());
        orderItem.setTotalFee(orderItemVO.getTotalFee());

        return orderItem;
    }


    public static OrderShipping orderShippingVOToOrderShipping(OrderShippingVO orderShippingVO) {

        OrderShipping orderShipping = new OrderShipping();

        orderShipping.setOrderId(orderShippingVO.getOrderId());
        orderShipping.setReceiverName(orderShippingVO.getReceiverName());
        orderShipping.setReceiverPhone(orderShippingVO.getReceiverPhone());
        orderShipping.setReceiverMobile(orderShippingVO.getReceiverMobile());
        orderShipping.setReceiverState(orderShippingVO.getReceiverState());
        orderShipping.setReceiverCity(orderShippingVO.getReceiverCity());
        orderShipping.setReceiverDistrict(orderShippingVO.getReceiverDistrict());
        orderShipping.setReceiverAddress(orderShippingVO.getReceiverAddress());
        orderShipping.setReceiverZip(orderShippingVO.getReceiverZip());

        return orderShipping;
    }


}
